package com.thinkgem.jeesite.modules.university.utils;

import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.thinkgem.jeesite.common.utils.SpringContextHolder;
import com.thinkgem.jeesite.modules.sys.entity.Dict;
import com.thinkgem.jeesite.modules.university.entity.University;
import com.thinkgem.jeesite.modules.university.service.UniversityService;

/**
 * 学校Utils
 * @author 朱俊吉
 * @version 2017-12-08
 */
public class UniversityUtils {
	
	private static UniversityService universityService = SpringContextHolder.getBean(UniversityService.class);
	
	public static List<Dict> getLevel(University university){
		return universityService.getLevelList(university);
	}
	
	/**
	 * 高校大全点击两次 移除该条件
	 */
	public static List<String> removeSame(List<String> list){
		List<String> result = Lists.newArrayList();
		Map<String, Integer> map = Maps.newHashMap();
		for (String key : list) {
			if(map.containsKey(key)){
				map.put(key, map.get(key)+1);
			}else{
				map.put(key, 1);
			}
		}
		//删除点击两次的
		Iterator<Map.Entry<String, Integer>> it = map.entrySet().iterator();
        while(it.hasNext()){  
            Map.Entry<String, Integer> entry=it.next();   
            if(entry.getValue() > 1){  
                it.remove(); 
            }  
        } 
		for (Entry<String, Integer> entry : map.entrySet()) {
			result.add(entry.getKey());
		}
		return result;
	}

}
